package com.wing.ext.dao;

import org.springframework.stereotype.Repository;

import com.wing.common.CommonSpringJDBC;
import com.wing.common.util.PageBean;
import com.wing.ext.domain.Messageboard;

@Repository
public class MessageboardDao extends CommonSpringJDBC<Messageboard, String> {

	public PageBean findPageList(int currentPage, int pageSize,String siteId, String sval) {
		String where= " site_id='"+siteId+"' ";
		if(sval!=null && !sval.trim().equals("")){
			where += " and title like '%"+sval+"%' ";
		}
		String sql1=" SELECT * FROM ext_messageboard where "+where+" ORDER BY createtime DESC " +
			" LIMIT "+(currentPage-1) * pageSize+","+pageSize;
		String sql2 = "select count(id) from  ext_messageboard  where"+where;
		String[] sqlArray = {sql1,sql2 };
		return super.findPageList(sqlArray, currentPage, pageSize); 
	}
	
}
